﻿#define _CRT_SECURE_NO_WARNINGS//模拟实现memmove
#include<stdio.h>
#include<string.h>
void* my_memmove(void* dest, void* src, size_t num)
{
	void* ret = dest;
	size_t nums = num;
	if (src < dest)
	{
		while (num--)
		{
			*((char*)dest + num) = *((char*)src + num);
		}
	}
	else
	{
		while (nums--)
		{
			*((char*)dest) = *((char*)src);
			(char*)dest = ((char*)dest + 1);
			(char*)src = ((char*)src + 1);
		}

	}
	return ret;
}
int main()
{
	int arr1[20] = { 1,2,3,4,5,6,7,8 };
	int arr2[] = { 7,8,9 };
	/*memmove(arr1, arr1 + 3, 8);*/
	my_memmove(arr1 + 3, arr1 + 1, 8);
	for (int i = 0; i < 20; i++)
	{
		printf("%d\n", arr1[i]);
	}
	return 0;
}